/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
  CCell,
  Cell,
  Table,
  TableBody,
  TableRow,
  Text,
  TableHead,
  useTheme,
  RCell,
  LineColumn,
  InputLine,
  CheckSwitch,
  Select,
  BlobInputList,
} from "customize-easy-ui-component";
import {DirectLink} from "../../routing/Link";
import {multilines2Html, zdBoth} from "../tools";
import {objNestSet} from "../../common/tool";
import {item安全附件o} from "./editorAcces";

//承压的相似度更高点
export const 安全附件检验= ({theme, orc, rep} :{theme: any, orc:any, rep:any}
) => {
  return <>
    <div css={{
      display: 'flex',
      justifyContent: 'space-between'
    }}>
      <Text>单位内部编号：{orc.单位内部编号}</Text>
      <Text>报告编号：{rep.isp.no}</Text>
    </div>
    <Table  fixed={ ["14%","%","15%","9%","15%","4%","25%"]  } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <DirectLink  href={`/report/${rep?.modeltype}/ver/${rep?.modelversion}/${rep?.id}/Accessories#Accessories`}>
        { item安全附件o.map(([name,title,noDesc,yesDesc,noDemand]: any, i:number) => {
            //设计7栏 【注意】特殊部分；配置总会有遗漏的，容易造成不一致性差错。 底下的“无检定要求”不能建议的使用orc?.[name]来做开关，只好引进：需要三态独立存储字段。
            return <React.Fragment key={i}><TableRow>
              <CCell rowSpan={3}>{title}</CCell><CCell>{noDesc}</CCell>
              <CCell colSpan={5}>{orc?.[name]?.no || '／'}</CCell>
            </TableRow>
            <TableRow>
              <CCell>数量</CCell><CCell colSpan={3}>{orc?.[name]?.s || '／'}</CCell><CCell>个</CCell><CCell></CCell>
            </TableRow>
            <TableRow>
              <CCell>{yesDesc}</CCell><CCell>( {('是'===orc?.[name]?.Y)? '√' : orc?.[name]?.Y? '':'／'} )是</CCell>
              <CCell></CCell><CCell>( {('否'===orc?.[name]?.Y)? '√' : orc?.[name]?.Y? '':'／'} )否</CCell>
              { noDemand ?
                 <><CCell></CCell><CCell>( {'是'===orc?.[name]?.IS && '√'} )无检定要求</CCell></>
                  :
                <CCell colSpan={2}></CCell>
              }
            </TableRow>
            </React.Fragment>
        }) }
          <TableRow><Cell colSpan={7}>备注：</Cell>
          </TableRow>
          <TableRow>
            <Cell split={true} colSpan={7}><div css={{minHeight: '3rem'}}>
                {multilines2Html(orc.附件备注 || '／', (txt, i) => {
                  return <React.Fragment key={i}>{(i !== 0) && <br/>}<Text css={{whiteSpace: 'break-spaces'}}>{txt}</Text></React.Fragment>
                })}
              </div></Cell>
          </TableRow>
          <TableRow><Cell colSpan={7}>发现问题描述：</Cell>
          </TableRow>
          <TableRow>
            <Cell split={true} colSpan={7}><div css={{minHeight: '3rem'}}>
                {multilines2Html(orc.附件问题 || '／', (txt, i) => {
                  return <React.Fragment key={i}>{(i !== 0) && <br/>}<Text css={{whiteSpace: 'break-spaces'}}>{txt}</Text></React.Fragment>
                })}
              </div></Cell>
          </TableRow>
        </DirectLink>
      </TableBody>
    </Table>
    <Table fixed={["62%", "%"]} css={{borderCollapse: 'collapse'}} tight miniw={800}>
      <TableBody>
        <TableRow>
          <CCell>
            <div css={{
              height: '100%',
              display: 'flex',
              justifyContent: 'space-between',
              alignContent: 'space-between',alignItems: 'flex-start'}}>
            <div><Text>检验：</Text>    </div>
            <div css={{textAlign: 'end'}}><Text >日期</Text>2022-12-31</div>
          </div></CCell>
          <CCell><div css={{height: '100%',display: 'flex',justifyContent: 'space-between',alignContent: 'space-between',alignItems: 'flex-start'}}>
            <div><Text >审核：</Text>  </div>
            <div css={{textAlign: 'end'}}><Text >日期</Text>2021-01-31</div>
          </div></CCell>
        </TableRow>
      </TableBody>
    </Table>
  </>;
};


